﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SetAlarmGrp.aspx.cs" Inherits="iEN.Alarm.SetAlarmGrp" %>
<%@ Register src="../UserControl/TopMenu.ascx" tagname="TopMenu" tagprefix="uc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>告警群組成員設定</title>
</head>
<body>
    <form id="form1" runat="server">
    <center>
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        </div>
        <table style="width: 952px" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
            <tr>
                <td>
                    <uc2:TopMenu ID="TopMenu1" runat="server" />
                </td>
            </tr>
            <tr>
            <td style="background-image:url('../images/title_back.gif')" align="center" ; width="952px" >
                    <asp:Label ID="Label1" runat="server" Text="告警群組成員設定" BackColor="Transparent" style="color:Blue;background-color:Transparent;font-family:微軟正黑體,新細明體,標楷體,Arial,sans-serif;font-size:XX-Large;"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Label ID="lblMsg" runat="server" Font-Names="微軟正黑體" Font-Size="X-Large"  ForeColor="Red" Text="你沒有瀏覽此頁面的權限" Visible="False"></asp:Label>
                    <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                        <ContentTemplate>
                            <asp:ImageButton ID="imgTip" runat="server" ImageUrl="~/images/info_show.gif" OnClick="imgTip_Click"
                                ToolTip="按我顯示或隱藏設定說明" />
                            <asp:Panel ID="Panel2" runat="server" BackColor="#FFFFC0" GroupingText="告警群組說明" Width="800px"
                                Visible="False">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/flag.gif" /><asp:Label ID="Label2"
                                    runat="server" Font-Size="10pt" ForeColor="Blue" Text="請先新增告警群組以及告警人員，再設定告警群組成員。"></asp:Label><br />
                                <asp:Image ID="Image3" runat="server" ImageUrl="~/images/flag.gif" /><asp:Label ID="Label5"
                                    runat="server" Font-Size="10pt" ForeColor="Blue" Text="新增告警群組時預設群組為啟用，可於告警群組列表設定是否啟用。"></asp:Label></asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" >
                        <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
                            <HeaderTemplate>
                                增刪告警通報群組
                            </HeaderTemplate>
                            <ContentTemplate>
                                <asp:Panel ID="Panel4" runat="server" BackColor="PowderBlue" GroupingText="告警群組設定" Width="600px"
                                    Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                    <img src="../images/dot01.gif" /><asp:Label ID="lblAlarmGrpID" runat="server" ForeColor="Black"
                                        Text="告警群組名稱："></asp:Label>
                                    <asp:TextBox ID="tbxAlarmGrpName" runat="server" Width="150px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvAlarmGrp" runat="server" ControlToValidate="tbxAlarmGrpName"
                                        CssClass="note" Display="Dynamic" ErrorMessage="(必填)" ValidationGroup="valAlarmGrpAdd"></asp:RequiredFieldValidator>&nbsp;
                                    <br />
                                    <asp:Button ID="btnAlarmGrpAdd" runat="server" CssClass="graybtn" OnClick="btnAlarmGrpAdd_Click"
                                        Text="新增告警群組" ValidationGroup="valAlarmGrpAdd" />
                                    <asp:Label ID="lblPriInfo" runat="server" ForeColor="Red"></asp:Label>
                                </asp:Panel>
                                <br />
                                <asp:Panel ID="Panel5" runat="server" BackColor="PowderBlue" GroupingText="告警群組列表" Width="600px"
                                             Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                    <ContentTemplate>
                                        
                                        <asp:GridView ID="gvAlarmGrp" runat="server" BackColor="White" BorderColor="#336666"
                                            BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                            AutoGenerateColumns="False" Width="580px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                            Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif"
                                            DataSourceID="AlarmGrpDataSource"
                                            OnRowCommand="gvAlarmGrp_RowCommand"
                                            OnRowUpdating="gvAlarmGrp_RowUpdating"
                                            OnRowUpdated="gvAlarmGrp_RowUpdated"
                                            DataKeyNames="_id"
                                            HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                            <RowStyle BackColor="White" ForeColor="#333333" />
                                            <Columns>
                                                
                                                <asp:BoundField DataField="_name" HeaderText="告警群組名稱" SortExpression="_name">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:TemplateField HeaderText="啟用">
                                                    <EditItemTemplate>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("_enabled") %>' />
                                                    </EditItemTemplate>
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("_enabled") %>'
                                                            Enabled="False" />
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                                <asp:CommandField ShowEditButton="True" />
                                                <asp:TemplateField ShowHeader="False">
                                                    <ItemTemplate>
                                                        <asp:Button ID="btnDelAlarmGrp" runat="server" CausesValidation="false"
                                                            CommandName="Del" OnClientClick="return confirm('將刪除告警群組、群組成員設定及所有告警中有用到該群組之資料, 確定要刪除??');"
                                                            CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" Text="刪除" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                            <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                HorizontalAlign="Center" />
                                            <PagerSettings Position="TopAndBottom" />
                                            <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                            <AlternatingRowStyle BackColor="Azure" />
                                            <EmptyDataTemplate>
                                                <table>
                                                    <tr>
                                                        <td style="font-size: 20; color: Red;">
                                                            無告警群組資料...
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                        <asp:ObjectDataSource ID="AlarmGrpDataSource" runat="server" 
                                            SelectMethod="getAlarmGrpTable" TypeName="DataAccess.DBAccess" 
                                            UpdateMethod="updateAlarmGrp">
                                            <UpdateParameters>
                                                <asp:Parameter Name="_id" />
                                                <asp:SessionParameter Name="_enabled" SessionField="_enabled" />
                                            </UpdateParameters>
                                        </asp:ObjectDataSource>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="btnAlarmGrpAdd" EventName="Click" />
                                    </Triggers>
                                </asp:UpdatePanel>
                                </asp:Panel>
                            </ContentTemplate>
                            
                        </cc1:TabPanel>
                        <cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3" >
                            <HeaderTemplate>
                                增刪告警通報人員
                            </HeaderTemplate>
                            <ContentTemplate>
                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                    <ContentTemplate>
                                        <asp:Panel ID="Panel3" runat="server" BackColor="PowderBlue" GroupingText="告警人員設定" Width="700px"
                                             Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                            <img src="../images/dot01.gif" />
                                            <asp:Label ID="lblAlarmMemberName" runat="server" ForeColor="Black" Text="姓名："></asp:Label><asp:TextBox
                                                ID="tbxAlarmMemberName" runat="server" Width="100px"></asp:TextBox><asp:RequiredFieldValidator
                                                    ID="rfvAlarmMemberName" runat="server" ControlToValidate="tbxAlarmMemberName" Display="Dynamic"
                                                    ErrorMessage="(必填)" ValidationGroup="valAlarmMemberSave"></asp:RequiredFieldValidator>
                                            <br />
                                            <img src="../images/dot01.gif" />
                                            <asp:Label ID="lblAlarmMemberPhone" runat="server" ForeColor="Black" Text="行動電話："></asp:Label><asp:TextBox
                                                ID="tbxAlarmMemberPhone" runat="server" Width="140px"></asp:TextBox>
                                                <asp:RequiredFieldValidator
                                                    ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbxAlarmMemberPhone" Display="Dynamic"
                                                    ErrorMessage="(必填)" ValidationGroup="valAlarmMemberSave"></asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator
                                                    ID="revAlarmMemberPhone" runat="server" ControlToValidate="tbxAlarmMemberPhone" CssClass="note"
                                                    Display="Dynamic" ErrorMessage="(09xxxxxxxx)" ValidationExpression="[0][9][0-9]{8}"
                                                    ValidationGroup="valAlarmMemberSave"></asp:RegularExpressionValidator><br />
                                            <img src="../images/dot01.gif" />
                                            <asp:Label ID="lblAlarmMemberEmail" runat="server" ForeColor="Black" Text="Email："></asp:Label><asp:TextBox
                                                ID="tbxAlarmMemberEmail" runat="server" Width="180px"></asp:TextBox>
                                                <asp:RequiredFieldValidator
                                                    ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbxAlarmMemberEmail" Display="Dynamic"
                                                    ErrorMessage="(必填)" ValidationGroup="valAlarmMemberSave"></asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator
                                                    ID="refAlarmMemberEmail" runat="server" ControlToValidate="tbxAlarmMemberEmail" CssClass="note"
                                                    Display="Dynamic" ErrorMessage="(email格式錯誤)" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                    ValidationGroup="valAlarmMemberSave"></asp:RegularExpressionValidator><br />
                                            <img src="../images/dot01.gif" />
                                            <asp:Label ID="lblAlarmMemberDesc" runat="server" ForeColor="Black" Text="告警人員描述："></asp:Label><asp:TextBox
                                                ID="tbxAlarmMemberDesc" runat="server" Width="140px"></asp:TextBox><br />
                                            &nbsp;<asp:Button ID="btnAlarmMemberAdd" runat="server" CssClass="graybtn" OnClick="btnAlarmMemberAdd_Click"
                                                Text="新增告警人員" ValidationGroup="valAlarmMemberSave" /><asp:Label ID="lblAlarmMemberInfo" runat="server"
                                                    ForeColor="Red"></asp:Label></asp:Panel>
                                        <br />
                                        <asp:Panel ID="Panel6" runat="server" BackColor="PowderBlue" GroupingText="告警人員列表"
                                            Width="700px" Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                            <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                                <ContentTemplate>
                                                    <asp:GridView ID="gvAlarmMember" runat="server" BackColor="White" BorderColor="#336666"
                                                        BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                                        AutoGenerateColumns="False" Width="680px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                                        Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif" DataSourceID="AlarmMemberDataSource"
                                                        OnRowCommand="gvAlarmMember_RowCommand" OnRowUpdating="gvAlarmMember_RowUpdating" DataKeyNames="_id"
                                                        HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                                        <RowStyle BackColor="White" ForeColor="#333333" />
                                                        <Columns>
                                                            <asp:BoundField DataField="_name" HeaderText="姓名" SortExpression="_name">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_phone" HeaderText="行動電話" SortExpression="_phone">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_email" HeaderText="Email" SortExpression="_email">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_desc" HeaderText="告警人員描述" SortExpression="_desc">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:CommandField ShowEditButton="True" />
                                                            <asp:TemplateField ShowHeader="False">
                                                                <ItemTemplate>
                                                                    <asp:Button ID="btnDelAlarmMember" runat="server" CausesValidation="false" CommandName="Del"
                                                                        OnClientClick="return confirm('將刪除告警人員、群組成員設定及所有告警中有用到該人員之資料, 確定要刪除??');" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                                                        Text="刪除" />
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                        </Columns>
                                                        <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                            HorizontalAlign="Center" />
                                                        <PagerSettings Position="TopAndBottom" />
                                                        <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                                        <AlternatingRowStyle BackColor="Azure" />
                                                        <EmptyDataTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td style="font-size: 20; color: Red;">
                                                                        無告警人員資料...
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </EmptyDataTemplate>
                                                    </asp:GridView>
                                                    <asp:ObjectDataSource ID="AlarmMemberDataSource" runat="server" SelectMethod="getAlarmMemberTable"
                                                        TypeName="DataAccess.DBAccess" UpdateMethod="updateAlarmMember">
                                                        <UpdateParameters>
                                                            <asp:Parameter Name="_id" />
                                                        </UpdateParameters>
                                                    </asp:ObjectDataSource>
                                                </ContentTemplate>
                                                <Triggers>
                                                    <asp:AsyncPostBackTrigger ControlID="btnAlarmMemberAdd" EventName="Click" />
                                                </Triggers>
                                            </asp:UpdatePanel>
                                        </asp:Panel>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </ContentTemplate>
                        </cc1:TabPanel>
                        <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
                            <HeaderTemplate>
                                告警通報群組成員設定
                            </HeaderTemplate>
                            <ContentTemplate>
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <asp:Panel ID="Panel1" runat="server" BackColor="PowderBlue" GroupingText="告警群組成員設定" Width="700px"
                                             Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                            <img src="../images/dot01.gif" /><asp:Label ID="Label13" runat="server" ForeColor="Black"
                                                Text="選擇告警群組："></asp:Label><asp:DropDownList ID="ddlAlarmGrp" runat="server" AutoPostBack="True"
                                                    OnDataBound="ddlAlarmGrp_DataBound" OnSelectedIndexChanged="ddlAlarmGrp_SelectedIndexChanged"
                                                    ValidationGroup="None">
                                                </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlAlarmGrp"
                                                CssClass="note" Display="Dynamic" ErrorMessage="(必需有資料)" ValidationGroup="valSet"></asp:RequiredFieldValidator>
                                            
                                            <br />
                                            <img src="../images/dot01.gif" /><asp:Label ID="Label8" runat="server" ForeColor="Black"
                                                Text="選擇告警群組成員："></asp:Label>
                                            <asp:DropDownList ID="ddlAlarmMember" runat="server" AutoPostBack="True" Width="144px"
                                                OnDataBound="ddlAlarmMember_DataBound" OnSelectedIndexChanged="ddlAlarmMember_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlAlarmMember"
                                                CssClass="note" Display="Dynamic" ErrorMessage="(必需有資料)" ValidationGroup="valSet"></asp:RequiredFieldValidator>
                                            <br />
                                            &nbsp;&nbsp;
                                            <asp:Label ID="Label10" runat="server" ForeColor="Black" Text="行動電話："></asp:Label>
                                            <asp:Label ID="lblMobileTel" runat="server"></asp:Label><br />
                                            &nbsp;&nbsp; 
                                            <asp:Label ID="Label11" runat="server" ForeColor="Black" Text="EMail："></asp:Label>
                                            <asp:Label ID="lblEmail" runat="server"></asp:Label><br />
                                            &nbsp;&nbsp;
                                            <asp:Label ID="Label3" runat="server" ForeColor="Black" Text="告警人員描述："></asp:Label>
                                            <asp:Label ID="lblDesc" runat="server"></asp:Label><br />
                                            <asp:Button ID="btnSet" runat="server" CssClass="graybtn" OnClick="btnSet_Click"
                                                Text="新增" ValidationGroup="valSet" /><asp:Label ID="lblInfo" runat="server" ForeColor="Red"></asp:Label></asp:Panel>
                                        &nbsp;
                                        <asp:Label ID="lblNoMember" runat="server" ForeColor="Red" Text="此群組下並無成員" Visible="False"></asp:Label><br />
                                        <asp:Panel ID="Panel7" runat="server" BackColor="PowderBlue" GroupingText="告警群組成員列表"
                                            Width="700px" Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                            <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                                                <ContentTemplate>
                                                    <asp:GridView ID="gvAlarmGrpMember" runat="server" BackColor="White" BorderColor="#336666"
                                                        BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                                        AutoGenerateColumns="False" Width="680px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                                        Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif"
                                                        OnRowCommand="gvAlarmGrpMember_RowCommand"
                                                        HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                                        <RowStyle BackColor="White" ForeColor="#333333" />
                                                        <Columns>
                                                            <asp:BoundField DataField="_groupname" HeaderText="告警群組名稱" SortExpression="_groupname">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_username" HeaderText="告警成員姓名" SortExpression="_username">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_phone" HeaderText="行動電話" SortExpression="_phone">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_email" HeaderText="Email" SortExpression="_email">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="_desc" HeaderText="告警人員描述" SortExpression="_desc">
                                                                <ItemStyle HorizontalAlign="Center" />
                                                            </asp:BoundField>
                                                            <asp:TemplateField ShowHeader="False">
                                                                <ItemTemplate>
                                                                    <asp:Button ID="btnDelAlarmGrpMember" runat="server" CausesValidation="false" CommandName="Del"
                                                                        OnClientClick="return confirm('確定要刪除??');" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                                                        Text="刪除" />
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                        </Columns>
                                                        <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                            HorizontalAlign="Center" />
                                                        <PagerSettings Position="TopAndBottom" />
                                                        <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                                        <AlternatingRowStyle BackColor="Azure" />
                                                        <EmptyDataTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td style="font-size: 20; color: Red;">
                                                                        無告警群組成員資料...
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </EmptyDataTemplate>
                                                    </asp:GridView>
                                                    
                                                </ContentTemplate>
                                                <Triggers>
                                                    <asp:AsyncPostBackTrigger ControlID="btnSet" EventName="Click" />
                                                </Triggers>
                                            </asp:UpdatePanel>
                                        </asp:Panel>
                                            
                                        </asp:ObjectDataSource>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </ContentTemplate>
                        </cc1:TabPanel>
                    </cc1:TabContainer>
                </td>
            </tr>
                        
        </table>
    </center>
    </form>
</body>
</html>
